

census <- read.csv("./_3_data/1930_census/1930_census_houses.csv")


chinese <- census[census$RACE == "CHINESE",]

mod1 <- lm(BRICK.HOUSES ~ OPIUM, data = census %>% filter(RACE == "CHINESE"))
mod2 <- lm(BRICK.HOUSES ~ OPIUM + TOTAL.FOREIGN.ASIATICS, data = census %>% filter(RACE == "CHINESE"))
mod3 <- lm(BRICK.HOUSES ~ OPIUM + RESIDENCY, data = census %>% filter(RACE == "CHINESE"))

mod4 <- lm(BRICK.HOUSES ~ OPIUM, data = census %>% filter(RACE == "JAVANESE"))
mod5 <- lm(BRICK.HOUSES ~ OPIUM + TOTAL.FOREIGN.ASIATICS, data = census %>% filter(RACE == "JAVANESE"))
mod6 <- lm(BRICK.HOUSES ~ OPIUM + RESIDENCY, data = census %>% filter(RACE == "JAVANESE"))

table = 
  stargazer(mod1, mod2, mod3, mod4, mod5, mod6,
          keep = c("OPIUM", "TOTAL.FOREIGN.ASIATICS", "Constant"),
          title = "\\textsc{Relationship Between Opium Concession System and Wealth (1930)}",
          label = "tab:census",
          column.labels = c("Chinese", "Javans"),
          column.separate = c(3,3),
          dep.var.labels.include = FALSE,
          dep.var.caption = "\\% Living in a Brick House (1930)",
          covariate.labels = c("Opium Legal", "Total Population", "Constant"),
          add.lines = list(c("Residency Fixed Effects?", "No", "No", "Yes","No", "No", "Yes")),
          keep.stat = "n")

note_text = "Beta coefficients from OLS regression. District-level population controls included. 
              Conventional standard errors clustered at the district level."

table =
table[-c(17, 20, 23, 29)] %>%
  append(., "\\cline{2-4} \\cline{5-7}", after = 12)

write_latex_placebo(table, note_text, './_4_outputs/tables/1_mech_outcomes_census.tex', scale = 0.8)

